Moved SuSE-specific getcfg call into a preiftransfer call. The semantics of
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 25 Oct 2005 10:22:47 +0000 (11:22 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 25 Oct 2005 10:22:47 +0000 (11:22 +0100)
this aren't beautiful, but this gets the distro-specific code out of the body
of the network-bridge script and into a common place, while still preserving
the existing code behaviour.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/examples/network-bridge
tools/examples/xen-network-common.sh

index c9d00b8e81d3d589c51881264459431510564ebf..e9a75ea749eae053203e62e421ae47b7ef952abf 100755 (executable)
@@ -208,7 +208,7 @@ op_start () {
 
     if ip link show ${vdev} 2>/dev/null >/dev/null; then
        mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
-       eval `/sbin/getcfg -d /etc/sysconfig/network/ -f ifcfg- -- ${netdev}`
+       preiftransfer ${netdev}
        transfer_addrs ${netdev} ${vdev}
        if ! ifdown ${netdev}; then
            # if ifup didn't work, see if we have an ip= on cmd line
@@ -231,7 +231,7 @@ op_start () {
        ip link set ${bridge} up
        ip link set ${vif0} up
        ip link set ${pdev} up 
-       if ! ifup ${HWD_CONFIG_0} ${netdev} ; then
+       if ! ifup ${netdev} ; then
            if [ ${kip} ] ; then
                # use the addresses we grocked from /proc/cmdline
                if [ -z "${kmask}" ]; then 
index d4af3990ca342e1458852b41eac0b5d26f6f4707..c2fc311fac956e400b857c76ba89ad80a7cd6ab3 100644 (file)
 #
 
 
-# Gentoo doesn't have ifup/ifdown: define appropriate alternatives
-if ! which ifup >&/dev/null
+# On SuSE it is necessary to run a command before transfering addresses and
+# routes from the physical interface to the virtual.  This command creates a
+# variable $HWD_CONFIG_0 that specifies the appropriate configuration for
+# ifup.
+
+# Gentoo doesn't have ifup/ifdown, so we define appropriate alternatives.
+
+# Other platforms just use ifup / ifdown directly.
+
+##
+# preiftransfer
+#
+# @param $1 The current name for the physical device, which is also the name
+#           that the virtual device will take once the physical device has
+#           been renamed.
+
+if [ -e /etc/SuSE-release ]
+then
+  preiftransfer()
+  {
+    eval `/sbin/getcfg -d /etc/sysconfig/network/ -f ifcfg- -- $1`
+  }
+  ifup()
+  {
+    /sbin/ifup ${HWD_CONFIG_0} $1
+  }
+elif ! which ifup >&/dev/null
 then
   if [ -e /etc/conf.d/net ]
   then
+    preiftransfer()
+    {
+      true
+    }
     ifup()
     {
       /etc/init.d/net.$1 start
@@ -34,4 +63,9 @@ then
       "You don't have ifup and don't seem to be running Gentoo either!"
     exit 1
   fi
+else
+  preiftransfer()
+  {
+    true
+  }
 fi